package cn.gson.crm.control.follow;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.FollowDao;
@WebServlet("/follow/insert")
public class FollowInsertServlet extends BaseServlet{
	private FollowDao followDao = new FollowDao();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String stuid = request.getParameter("stuid");
		String staffid = request.getParameter("staffid");
		String followStyle = request.getParameter("followStyle");
		String followAgainTime = request.getParameter("followAgainTime");
		String followContent = request.getParameter("followContent");
		followDao.insertFollowPoList(stuid, staffid, followStyle, followAgainTime, followContent);
		request.removeAttribute("stuid");
		request.removeAttribute("staffid");
		request.setAttribute("stuid", stuid);
		request.setAttribute("staffid", staffid);
		forward("../../allot/one");
	}
	
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String staid = request.getParameter("staid");
		String stuid = request.getParameter("stuid");
		int id = followDao.getstuSta(staid, stuid);
		request.setAttribute("id", id);
		response.setContentType("application/json;charset=utf-8");
    	String jsonStr = JSONArray.toJSONString(id);
        //输出结果
        response.getWriter().append(jsonStr);
	}

}
